<template lang="pug">
.pacs-viewer-dialog
  Dialog(
    v-model="model"
    cancel-text="取消"
    size="large"
    
    title="查看影像"
    v-bind:onCancel="onCancel"
    v-bind:onConfirm="onConfirm"
    v-bind:onClose="onClose",
    :hide-footer="true"
    :fullscreen="true"
    :no-padding="true"
  )
    cornerstone(:registrationIds="registrationIds",:deviceId="deviceId",@handleSave="handleSave")
</template>

<script setup lang="ts">
import { Dialog } from "@scmt/common-components";
import cornerstone from "../../pacsViewer/components/cornerstone.vue"
//添加 Props属性
const props = defineProps({
  registrationIds: {
    type: String,
    defaulte: ""
  },
  deviceId: {
    type: String,
    defaulte: ""
  },

});
const registrationIds = ref("");
const deviceId = ref("");
const model = defineModel({
  default: false,
});
//定义事件
const emit = defineEmits(['handleQuery']);
/**
 * 结论保存触发
 */
const handleSave = () => {
  emit("handleQuery");
  model.value = false;
}
//弹框点击确认事件
const onConfirm = () => {
  model.value = false;
};
//关闭弹框
const onCancel = () => {
  model.value = false;
};
//取消
const onClose = () => {
  model.value = false;
};

/**
 * 查找模板数据
 * @param templatejson 模板json
 * @param key 查询的key
 * @param resKey  需要的返回值
 */
const quaryData = (templatejson: any, key: any, resKey: any): boolean => {
  let res = false;
  if (templatejson && key) {


    if (templatejson.content && templatejson.content.length > 0) {
      if (templatejson.attrs && key == templatejson.attrs.name) {
        resKey.value = templatejson.content[0].text
        res = true;
        return res;
      }
      for (let index = 0; index < templatejson.content.length; index++) {
        const element = templatejson.content[index];
        let resFor = quaryData(element, key, resKey);
        if (resFor) {
          res = resFor;
          break;
        }
      }
    }
  }
  return res;
};
watch(
  model,
  () => {
    registrationIds.value = "";
    deviceId.value = "";
    if (model.value) {
      registrationIds.value = props.registrationIds ?? "";
      deviceId.value = props.deviceId ?? "";
    }
  },
  {
    immediate: true,
  }
);
</script>

<style lang="less" scoped>
.pacs-viewer-dialog {
  :deep(.mt-dialog__modal) {
    height: 100vh !important;

  }
}
</style>